home *** CD-ROM | disk | FTP | other *** search
- /* internal.h
- * AUTHOR: Cy Booker, cy@cheepnis.demon.co.uk
- * LICENSE: FreeWare, Copyright (c) 1995 Cy Booker
- * PURPOSE: common code
- */
-
- #ifndef internal_h
- #define internal_h
-
-
-
- #include "16bpp_66bit.h"
-
- #include "gif2rpc:map16bpp.h"
-
-
-
- /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- */
-
- /*
- * pre-processor macros so that do not pollute name space of library user
- */
-
- #define initialise_scaling_tables process_gif_16bpp_66bit__initialise_scaling_tables
- #define Gscale_8bit_to_22bit process_gif_16bpp_66bit__Gscale_8bit_to_22bit
- #define Gscale_5bit_to_22bit process_gif_16bpp_66bit__Gscale_5bit_to_22bit
-
-
-
- /*
- * SCALE is how we represent full intensity
- * it is large so that we can keep track of low errors (ie when we divide the error by 16)
- * must be able to handle +/-1*0xff*SCALE
- * <could remove this restriction if compute the scale[] and map[] arrays using double arithmetic>
- * anyway, will need to handle 0x1f * SCALE in 32 (unsigned) bits
- *
- * we choose as a power of 2 so that compiler can divide by SCALE just by shifting
- *
- */
- #define SCALE (1 << 22)
-
-
-
- #define INPUT \
- t = palette[rove[x]]; /* source pixel palette entry */\
- r = Gscale_8bit_to_22bit[(t >> 8) & 0xff]; /* scale to internal representation */\
- g = Gscale_8bit_to_22bit[(t >> 16) & 0xff];\
- b = Gscale_8bit_to_22bit[(t >> 24) & 0xff]
-
-
-
- #define PROCESS \
- r = MAX(r, 0); r = MIN(r, SCALE); /* ensure in range */\
- g = MAX(g, 0); g = MIN(g, SCALE);\
- b = MAX(b, 0); b = MIN(b, SCALE);\
- or = ((bits)(r * 0x1f) + (SCALE / 2)) / (bits)SCALE; /* scale to output */\
- og = ((bits)(g * 0x1f) + (SCALE / 2)) / (bits)SCALE;\
- ob = ((bits)(b * 0x1f) + (SCALE / 2)) / (bits)SCALE;\
- t = or | (og << 5) | (ob << 10);\
- *(((short *)rove) + x) = t; /* write pixel */\
- assert((or >= 0) && (or <= 0x1f));\
- assert((og >= 0) && (og <= 0x1f));\
- assert((ob >= 0) && (ob <= 0x1f));\
- or = Gscale_5bit_to_22bit[or]; /* calculate actual colour output */\
- og = Gscale_5bit_to_22bit[og];\
- ob = Gscale_5bit_to_22bit[ob]
-
-
- /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- */
-
- extern int Gscale_8bit_to_22bit[256]; /* 0..0xff -> n*SCALE/0xff */
- extern int Gscale_5bit_to_22bit[32]; /* 0..0x1f -> n*SCALE/0x1f */
-
-
-
- /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- * this will initialise the tables once only
- */
-
- extern void initialise_scaling_tables(void);
-
-
-
- #endif /* internal_h */
-